package com.yanqu.road.entity.activity.pawnshop;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

import com.alibaba.fastjson.JSON;
import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

/**
 * 玩家的当铺数据
 * 
 * @author sjh
 *
 */
@FieldTypeAnnotation(tableName = "t_u_activity_pawnshop")
public class UserPawnshop extends DataObject {

	@FieldTypeAnnotation(select = true, update = true, desc = "用户ID")
	private long userId;

	@FieldTypeAnnotation(select = true, update = true, desc = "活动ID")
	private int activityId;

	@FieldTypeAnnotation(desc = "已接待人数，用于换算成经营天数")
	private int receptionNum;

	@FieldTypeAnnotation(desc = "当铺等级")
	private int level;

	@FieldTypeAnnotation(desc = "可用的当铺币")
	private long coinUsable;

	@FieldTypeAnnotation(desc = "当天洗脑次数")
	private int washTimes;

	@FieldTypeAnnotation(desc = "可用的体力，用于接待npc")
	private int staminaUsable;

	@FieldTypeAnnotation(desc = "上次恢复体力的时间戳")
	private long lastRestoreTime;

	// 进行中的时事记录///////////////////////////////////////////////////////////////////
	@FieldTypeAnnotation(desc = "时事编号，0即无")
	private int politicsEventId;
	
	@FieldTypeAnnotation(desc = "时事加成效果，正负值")
	private int politicsAddition;

	@FieldTypeAnnotation(desc = "时事开始接待人数")
	private int politicsStartReceptionNum;
	private int politicsTriggerRate;          //时事触发概率
	private boolean politicsRead;           //时事是否已读

	private String npcIcon;
	private boolean reception;

	private int lvReward;

	private Map<Integer, UserPawnshopStaff> staffMap = new ConcurrentHashMap<>();

	// ========================================================================
	public long getUserId() {
		return userId;
	}
	public void setUserId(long userId) {
		if (this.userId != userId) {
			this.userId = userId;
			setUpdateOption();
		}
	}

	public int getActivityId() {
		return activityId;
	}
	public void setActivityId(int activityId) {
		if (this.activityId != activityId) {
			this.activityId = activityId;
			setUpdateOption();
		}
	}

	public int getReceptionNum() {
		return receptionNum;
	}
	public void setReceptionNum(int receptionNum) {
		if (this.receptionNum != receptionNum) {
			this.receptionNum = receptionNum;
			setUpdateOption();
		}
	}

	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		if (this.level != level) {
			this.level = level;
			setUpdateOption();
		}
	}

	public long getCoinUsable() {
		return coinUsable;
	}
	public void setCoinUsable(long coinUsable) {
		if (this.coinUsable != coinUsable) {
			this.coinUsable = coinUsable;
			setUpdateOption();
		}
	}

	public int getStaminaUsable() {
		return staminaUsable;
	}
	public void setStaminaUsable(int staminaUsable) {
		if (this.staminaUsable != staminaUsable) {
			this.staminaUsable = staminaUsable;
			setUpdateOption();
		}
	}

	public int getPoliticsEventId() {
		return politicsEventId;
	}
	public void setPoliticsEventId(int politicsEventId) {
		if (this.politicsEventId != politicsEventId) {
			this.politicsEventId = politicsEventId;
			setUpdateOption();
		}
	}

	public int getPoliticsAddition() {
		return politicsAddition;
	}
	public void setPoliticsAddition(int politicsAddition) {
		if (this.politicsAddition != politicsAddition) {
			this.politicsAddition = politicsAddition;
			setUpdateOption();
		}
	}

	public String getStaffMapJsonStr(){
		return JSON.toJSONString(staffMap);
	}

	public Map<Integer, UserPawnshopStaff> getStaffMap() {
		return staffMap;
	}

	public void setStaffMap(Map<Integer, UserPawnshopStaff> staffMap) {
		this.staffMap = staffMap;
		setUpdateOption();
	}

	public int getStaffLv(int staffType){
		UserPawnshopStaff staff = staffMap.get(staffType);
		if(null != staff){
			return staff.getLevel();
		}
		return 0;
	}

	public UserPawnshopStaff addStaffLv(int staffType){
		int level = getStaffLv(staffType);
		level++;
		UserPawnshopStaff staff = staffMap.get(staffType);
		if(null == staff){
			staff = new UserPawnshopStaff();
			staff.setStaffType(staffType);
			staffMap.put(staffType, staff);
		}
		staff.setLevel(level);
		setUpdateOption();
		return staff;
	}

	public int getWashTimes() {
		return washTimes;
	}

	public void setWashTimes(int washTimes) {
		if(this.washTimes != washTimes) {
			this.washTimes = washTimes;
			setUpdateOption();
		}
	}

	public long getLastRestoreTime() {
		return lastRestoreTime;
	}

	public void setLastRestoreTime(long lastRestoreTime) {
		if(this.lastRestoreTime != lastRestoreTime) {
			this.lastRestoreTime = lastRestoreTime;
			setUpdateOption();
		}
	}

	public int getPoliticsStartReceptionNum() {
		return politicsStartReceptionNum;
	}

	public void setPoliticsStartReceptionNum(int politicsStartReceptionNum) {
		if(this.politicsStartReceptionNum != politicsStartReceptionNum) {
			this.politicsStartReceptionNum = politicsStartReceptionNum;
			setUpdateOption();
		}
	}

	public int getPoliticsTriggerRate() {
		return politicsTriggerRate;
	}

	public void setPoliticsTriggerRate(int politicsTriggerRate) {
		if(this.politicsTriggerRate != politicsTriggerRate) {
			this.politicsTriggerRate = politicsTriggerRate;
			setUpdateOption();
		}
	}

	public boolean isPoliticsRead() {
		return politicsRead;
	}

	public void setPoliticsRead(boolean politicsRead) {
		if(this.politicsRead != politicsRead) {
			this.politicsRead = politicsRead;
			setUpdateOption();
		}
	}

	public String getNpcIcon() {
		return npcIcon;
	}

	public void setNpcIcon(String npcIcon) {
		if (!Objects.equals(this.npcIcon, npcIcon)) {
			this.npcIcon = npcIcon;
			setUpdateOption();
		}
	}

	public boolean isReception() {
		return reception;
	}

	public void setReception(boolean reception) {
		if (!Objects.equals(this.reception, reception)) {
			this.reception = reception;
			setUpdateOption();
		}
	}

	public int getLvReward() {
		return lvReward;
	}

	public void setLvReward(int lvReward) {
		if (!Objects.equals(this.lvReward, lvReward)) {
			this.lvReward = lvReward;
			setUpdateOption();
		}
	}
}
